{template 'common/header'}
<ul class="nav nav-tabs">
    <li ><a href="{php echo url('sms/template/list');}">短信内容模板列表</a></li>
    <li class="active"><a href="{php echo url('sms/template/post',array('id'=>$id));}">{if $id}编辑{else}新增{/if}短信内容模板</a></li>
</ul>
<div class="clearfix">
    <form class="form-horizontal form" action="{php echo url('sms/template/post');}" method="post" id="form1">
        <input type="hidden" name="id" value="{$row['id']}" />

        <div class="form-group">
            <label class="col-xs-12 col-sm-4 col-md-3 col-lg-2 control-label">标题：</label>
            <div class="col-sm-5">
                <input type="text" id="title" class="form-control" placeholder="请输入标题" name="title" value="{$row['title']}" />
            </div>
        </div>
        <div class="form-group">
            <label class="col-xs-12 col-sm-4 col-md-3 col-lg-2 control-label">模板分类：</label>
            <div class="col-sm-5">
                <select name="category" class="form-control">
                    {loop $category $k $v}
                    <option value="{$k}" {if $k=$item['category'] }selected{/if}>{$v}</option>
                    {/loop}
                </select>
             </div>
        </div>
        <div class="form-group">
            <label class="col-xs-12 col-sm-4 col-md-3 col-lg-2 control-label">模板内容：</label>
            <div class="col-sm-5">
                <textarea class="form-control" placeholder="添加短信模板内容" name="content"  id="content" >{$row['content']}</textarea>
            </div>
        </div>
        <div class="form-group">
            <label class="col-xs-12 col-sm-4 col-md-3 col-lg-2 control-label">状态：</label>
            <div class="col-sm-5" >
                <label class="radio-inline">
                    <input type="radio" name="status" {if $row['status']==1} checked{/if}  value="1"/>
                    启用
                </label>
                <label class="radio-inline">
                    <input type="radio" name="status" {if $row['status']==0} checked{/if}  value="0"/>
                    禁用
                </label>
            </div>
        </div>
        <div class="form-group">
            <label class="col-xs-12 col-sm-4 col-md-2 col-lg-1 control-label"></label>
            <div class="col-sm-10">
                <button type="submit" class="btn btn-primary" name="submit" value="提交">提交</button>
                <input type="hidden" name="token" value="{$_W['token']}" />
            </div>
        </div>
    </form>
</div>
<script type="text/javascript">
    require(['jquery', 'util'], function($, u){

        $("#form1").submit(function(){
            if(!$("#title").val()) {
                u.message('标题为必填项，请返回修改！！', '', 'error');
                return false;
            }
            if($("#content").val() == '') {
                u.message('模板内容为必填项，请返回修改！', '', 'error');
                return false;
            }
            return true;
        });
    });
</script>
{template 'common/footer'}